<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * CodeIgniter Order Library
 *
 * @package         CodeIgniter
 * @subpackage      Libraries
 * @category        Libraries
 * @author          Eason
 * @license         MIT
 */
class Bank {
    protected $ci;
    private $db;
    public function __construct() {
        $this->ci = & get_instance();
        $this->db = $this->ci->load->database('default',true);
    }

    //保存银行卡
    public function saveBank($array,$table='cny_bank'){
        $i = 1;
        $orderno = '';
        do {
            $rs = $this->db->insert($table,$array);
        }while(!$rs && $i++ < 5);

		if($rs){
			return $this->db->insert_id();
		}
        return false;
    }

    public function getBank($uid,$table='cny_bank'){
		$where = array('uid'=>$uid,'status'=>1);
        $query = $this->db->select()->from($table)->where($where)->limit(1)->get();
        if ($query->row()) {
            return $query->row_array();
        }

        return false;
    }

    public function updateBank($array,$where,$table='cny_bank'){
        $this->db->where($where);
        if(!$this->db->update($table, $array)){
            return false;
        }
        return true;
    }  
}

?>